c++ take n number from the user and store them in array and get the max, min number of them and also find the average-summation of these numbers

160

#include <iostream>
using namespace std;
int main(){
	int arr[10], n=10, i, max, min,avg;
	cout <<"Enter the numbers ";
	for(i=0;i<n;i++){
		cin >> arr[i];
	}	
	// for maximum value
	max = arr[0];
	for (i=0;i<n;i++){
		if (max < arr[i]){
			max = arr[i];
		}
	}
	// for minimum value
	min = arr[0];
	for (i=0;i<n;i++){
		if (min > arr[i]){
			min = arr[i];
		}
	}
	// average 
	int sum = 0;
	for (i=0;i<n;i++){
		sum += arr[i];
	}
	avg = sum/n;

	cout<<"Maximum number is :"<< max<<endl ;
	cout <<"Minimum number is :"<<min<<endl;
	cout<<"Average of numbers :"<< avg; 
	
}

Comments

Submit
0 Comments

More Questions

c++ vector printstring to char array c++ remove element by index from vector c++
cpp print vectorchange int to string cpp c++ throw exception
flutter convert datetime in day of monthflutter datetime format removing a character from a string in c++
DateFormat in Flutterconvert string to char c++ integer to string c++
create and write to a file c++19remove value from vector c++ conda list envs
c++ map iteratorvariadic template in c++ Lucky Four codechef solution in c++
throw exception c++c++ cin accept only numbers c++ take n number from the user and store them in array and get the max, min number of them and also find the average-summation of these numbers
change integer to string c++binary exponentiation modulo m initialize 2d vector as 0
cpp map containsc++ get file content for c++
char vector to string c++2d vector initialization in cpp mt19937 example c++
what is require to run min max function on linux in cppget first element of set c++ CPP Find options passed from command line
Max element in an array with the index in c++qt rotate qimage set elements to 42 back
Patrick and Shopping codeforces in c++boundary traversal of binary tree how to remove a index from a string in cpp
convert vector into array c++Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volod type defination in C++
hola mundo c++